package cn.edu.cug.cs.gtl.renders.openinventor.basics;

import cn.edu.cug.cs.gtl.apis.render.basics.Matrix;
import cn.edu.cug.cs.gtl.apis.render.basics.Plane;
import cn.edu.cug.cs.gtl.apis.render.basics.ViewVolume;
import com.openinventor.inventor.SbViewVolume;

public class ViewVolumeImpl implements ViewVolume {
    protected SbViewVolume nativeObject = new SbViewVolume();

    public ViewVolumeImpl(SbViewVolume nativeObject) {
        this.nativeObject = nativeObject;
    }

    @Override
    public Object getNativeObject() {
        return this.nativeObject;
    }

    @Override
    public boolean attach(Object nativeObject) {
        if(nativeObject instanceof SbViewVolume){
            this.nativeObject = (SbViewVolume) nativeObject;
            return true;
        }
        return false;
    }

    @Override
    public Object detach() {
        SbViewVolume r = this.nativeObject;
        this.nativeObject=null;
        return r;
    }

    @Override
    public Matrix getMatrix() {
        return new MatrixImpl(this.nativeObject.getMatrix());
    }

    @Override
    public float getDepth() {
        return this.nativeObject.getDepth();
    }

    @Override
    public float getHeight() {
        return this.nativeObject.getHeight();
    }

    @Override
    public Plane getPlane(float distFromEye) {
        return new PlaneImpl(this.nativeObject.getPlane(distFromEye));
    }

    @Override
    public float getWidth() {
        return this.nativeObject.getWidth();
    }
}
